package com.test.dababy.dababy_05_process.widget;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.test.dababy.R;
import com.test.dababy.dababy_01_launcher.Base_dababyApplication;
import com.test.dababy.dababy_05_process.Proces_dababysIn_dababyfo_Data;
import com.test.dababy.dababy_00_http.OkHttpUtil;


public class Ge_dababynderSe_dababylectViewManager extends BaseProc_dababyessWid_dababygetManager {

    private String haethe ="";
    private String yhhaertj54 ="";
    private String hrr ="";
    public void hjklyu(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getKtysgb()))
                    setHeser(String.valueOf(getHuiyhegh3())+ getHsrrt6()+ isHkjeo());
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }
    public void setKtysgb(String ktysgb) {this.haethe = ktysgb;}
    public void setHeser(String heser) {this.yhhaertj54 = heser;}
    public void setHaerttr(String haerttr) {this.hrr = haerttr;}
    public String getKtysgb() {return haethe;}
    public String getHeser() {return yhhaertj54;}
    public String getHaerttr() {return hrr;}




    private TextView titleTv;
    private View maleView,femaleView;
    private TextView maleTv,femaleTv;
    private ImageView maleCheckIv,femaleCheckIv;

    private boolean isMa_dababyle = false;

    public Ge_dababynderSe_dababylectViewManager(View view, Proces_dababysIn_dababyfo_Data data, String pageTag){
        super(view,data,pageTag);
    }

    @Override
    protected void in_dababyit(){

        titleTv = mView.findViewById(R.id.idpg_tv_title);
        maleView = mView.findViewById(R.id.idpg_view_male);
        femaleView = mView.findViewById(R.id.idpg_view_female);
        maleTv = mView.findViewById(R.id.idpg_tv_male);
        femaleTv = mView.findViewById(R.id.idpg_tv_female);
        maleCheckIv = mView.findViewById(R.id.idpg_iv_male_check);
        femaleCheckIv = mView.findViewById(R.id.idpg_iv_female_check);

        maleView.setOnClickListener(v -> setGender_dababy(true));
        femaleView.setOnClickListener(v -> setGender_dababy(false));

        setTi_dababytle(mDa_dababyta.getTitle_dababy());
        hjklyu();

    }

    @Override
    public boolean checkI_dababynput() {
        return true;
    }

    @Override
    public String getInp_dababyut() {
        return isMa_dababyle ? "MALE":"FEMALE";
    }

    public void setGender_dababy(boolean isMale){
        this.isMa_dababyle = isMale;
        if (isMale){

            maleView.setBackgroundResource(R.drawable.bg_dark_d_rc_border_main_2dp);
            maleTv.setTextColor(Base_dababyApplication.getInstant().getColor(R.color.main));
            maleCheckIv.setBackgroundResource(R.drawable.icon_gender_check_true);

            femaleView.setBackgroundResource(R.drawable.bg_dark_d_round_corner);
            femaleTv.setTextColor(Base_dababyApplication.getInstant().getColor(R.color.word_gray));
            femaleCheckIv.setBackgroundResource(R.drawable.icon_gender_check_false);

        }else {

            femaleView.setBackgroundResource(R.drawable.bg_dark_d_rc_border_main_2dp);
            femaleTv.setTextColor(Base_dababyApplication.getInstant().getColor(R.color.main));
            femaleCheckIv.setBackgroundResource(R.drawable.icon_gender_check_true);

            maleView.setBackgroundResource(R.drawable.bg_dark_d_round_corner);
            maleTv.setTextColor(Base_dababyApplication.getInstant().getColor(R.color.word_gray));
            maleCheckIv.setBackgroundResource(R.drawable.icon_gender_check_false);

        }

        OkHttpUtil.getInstance_dababy().uploadEventPoint(TAG, mDa_dababyta.getParamName_dababy().toUpperCase()+"_CLICK", getInp_dababyut());
    }

    public void setTi_dababytle(String title){
        if (TextUtils.isEmpty(title)) titleTv.setVisibility(GONE);
        else {
            titleTv.setVisibility(VISIBLE);
            titleTv.setText(title);
        }
    }

    @Override
    public void inputEmptyTip() {

    }
}
